/**
 * 
 */
package com.cn.daifaming.demoservice.common.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.apache.commons.configuration.PropertiesConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Administrator
 *
 */
public class ConfigUtil
{
	private static final Logger logger = LoggerFactory
			.getLogger(ConfigUtil.class);

	private static Properties pro = new Properties();

	private static PropertiesConfiguration pc = new PropertiesConfiguration();

	private static FileInputStream in = null;

	static
	{
		String classpath = Thread.currentThread().getContextClassLoader()
				.getResource("").getPath();
		String path = (new StringBuilder()).append(classpath).append("config")
				.append(File.separator).append("sysconfig.properties")
				.toString();
		try
		{
			in = new FileInputStream(path);
		} 
		catch (FileNotFoundException e)
		{
			logger.error("Not find file path.");
			e.printStackTrace();
		}
	}

	public static String getProperties(String key)
	{
		try
		{
			pro.load(in);
		}
        catch (IOException e)
		{
			logger.error("Not load file.");
			e.printStackTrace();
		}
		return pro.getProperty(key);
	}

	public static String getString(String key)
	{
		return pc.getString(key);

	}
}
